package com.fengchao.api.dao.usr;

import com.fengchao.api.dao.BaseMapper;
import com.fengchao.model.usr.UsrDeliveryAddress;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface UsrDeliveryAddressMapper extends BaseMapper<UsrDeliveryAddress> {

    /**
     * 根据userId和 isDefault查询地址  如果isDefault为null 则查询所有   默认地址倒序
     *
     * @param userId
     * @return
     */
    List<UsrDeliveryAddress> findUsrDeliveryAddressByUserId(@Param("userId") Integer userId, @Param("isDefault") Boolean isDefault);

    /**
     * 修改userId的默认地址 如果id为空则全部修改
     *
     * @param userId
     * @return
     */
    Integer updateUsrDeliveryAddressDefault(@Param("userId") Integer userId, @Param("isDefault") Boolean isDefault, @Param("id") Integer id);

    /**
     * 删除userId 和id的地址
     *
     * @param userId
     * @param id
     * @return
     */
    Integer delectUsrDeliveryAddress(@Param("userId") Integer userId, @Param("id") Integer id);


}